<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\UserAuth;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;

class UserAuthController extends AdminBaseController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new UserAuth(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $this->gridFilter($grid,'user_auth');
            $grid->column('uid');
//            $grid->column('country_id');
//            $grid->column('country_code');
            $grid->column('realname');
            $grid->column('id_card');
//            $grid->column('birthday');
//            $grid->column('address');
//            $grid->column('city');
//            $grid->column('postal_code');
//            $grid->column('extra');
//            $grid->column('phone');
//            $grid->column('type');
            $grid->column('front_img')->image(g_admin_image(), 30, 30);
            $grid->column('back_img')->image(g_admin_image(), 30, 30);
//            $grid->column('hand_img');
//            $grid->column('check_time');
//            $grid->column('primary_status');
            $grid->column('status')->using(tt_user_auth('', true));
            $grid->column('remark');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new UserAuth(), function (Show $show) {
            $show->field('id');
            $show->field('uid');
            $show->field('country_id');
            $show->field('country_code');
            $show->field('realname');
            $show->field('id_card');
            $show->field('birthday');
            $show->field('address');
            $show->field('city');
            $show->field('postal_code');
            $show->field('extra');
            $show->field('phone');
            $show->field('type');
            $show->field('front_img');
            $show->field('back_img');
            $show->field('hand_img');
            $show->field('check_time');
            $show->field('primary_status');
            $show->field('status');
            $show->field('remark');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new UserAuth(), function (Form $form) {
            $form->display('id');
            $form->text('uid');
//            $form->text('country_id');
//            $form->text('country_code');
            $form->text('realname');
            $form->text('id_card');
//            $form->text('birthday');
//            $form->text('address');
//            $form->text('city');
//            $form->text('postal_code');
//            $form->text('extra');
//            $form->text('phone');
//            $form->text('type');
            $form->image('front_img');
            $form->image('back_img');
//            $form->text('hand_img');
//            $form->text('check_time');
//            $form->text('primary_status');
            $form->select('status')->options(tt_user_auth('',true));
            $form->text('remark');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
